package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;

/**
 * 工作报告统计数据 枚举
 * @author zheng.li
 */
@Getter
public enum StatisticOptionEnum {

    /**
     * 新增客户数
     */
    CUSTOMER_ADD_COUNT("customerAddCount", "enum.statisticOption.name.customer_add_count",0),
    /**
     * 新增合同数
     */
    CONTRACT_ADD_COUNT("contractAddCount", "enum.statisticOption.name.contract_add_count", 1),
    /**
     * 新增合同金额
     */
    CONTRACT_AMOUNT("contractAmount", "enum.statisticOption.name.contract_amount",2),
    /**
     * 新增跟进记录
     */
    COMMUNICATE_ADD_COUNT("communicateAddCount", "enum.statisticOption.name.communicate_add_count",3),
    /**
     * 新增机会数
     */
    OPPORTUNITY_ADD_COUNT("opportunityAddCount", "enum.statisticOption.name.opportunity_add_count",3),

    /**
     * 新增机会金额
     */
    OPP_AMOUNT("oppAmount", "enum.statisticOption.name.opp_amount",4),
    /**
     * 新增回款金额
     */
    PAYMENT_SHEET_AMOUNT("paymentSheetAmount", "enum.statisticOption.name.payment_sheet_amount",5),
    ;
    private String attr;
    private String name;
    private int sort;

    StatisticOptionEnum(String attr, String name, int sort) {
        this.attr = attr;
        this.name = name;
        this.sort = sort;
    }


    public static List<StatisticOptionEnum> getAllEnum() {
        List<StatisticOptionEnum> list = new ArrayList<>();
        for (StatisticOptionEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    public static StatisticOptionEnum getByAttr(String alias) {
        for (StatisticOptionEnum cacheCode : values()) {
            if (cacheCode.getAttr().equals(alias)) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

}
